/*
 * Copyright (C) 2011, EADS France
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */

package xowl.interpreter.backends.rdf;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 *
 * @author Laurent WOUTERS
 */
public class XOWLDynamicNode implements RDFSubjectNode, RDFProperty {
    private xowl.lang.owl2.Expression dynExpression;
    private List<java.lang.Class> types;

    public xowl.lang.owl2.Expression getDynamicExpression() { return dynExpression; }
    public Collection<java.lang.Class> getTypes() { return types; }
    @Override public RDFNodeType getNodeType() { return RDFNodeType.Dynamic; }

    public XOWLDynamicNode(xowl.lang.owl2.Expression exp) {
        dynExpression = exp;
        types = new ArrayList<java.lang.Class>();
    }

    public void addType(java.lang.Class type) {
        if (!types.contains(type))
            types.add(type);
    }

    @Override public int hashCode() {
        int hash = 3;
        hash = 23 * hash + (this.dynExpression != null ? this.dynExpression.hashCode() : 0);
        return hash;
    }
    @Override public boolean equals(Object obj) {
        if (!(obj instanceof XOWLDynamicNode))
            return false;
        XOWLDynamicNode o = (XOWLDynamicNode)obj;
        return (o.dynExpression == this.dynExpression);
    }
    @Override public String toString() {
        return "<dyn>";
    }
}
